package com.woniu.utils;

import sun.misc.BASE64Encoder;

/**
 * @Description:
 * @Author: LXB
 * @date: 2023/7/17 17:40
 */
public class BASE64Util {
    public static String encoder(byte[] bytes){
        BASE64Encoder encoder = new BASE64Encoder();
        //转换成base64串
        String png_base64 = encoder.encodeBuffer(bytes).trim();
        //删除 \r\n
        png_base64 = png_base64.replaceAll("\n", "").replaceAll("\r", "");
        return "data:image/png;base64," + png_base64;
    }
}
